Repository navigation
feat(agents): Agent 资源库统一管理指令、技能、MCP 服务器和 Hooks,并逐条列出调用(API-45 0 内补充) - #223
Conversation
… 0 内补充)
- 清单 agents[] 新增可选 configuration {instructions?, skills?, files?, read?, edit?},新增权限 agents.configuration;
安装审查新增 agentConfiguration 程序,Agent 目录条目带 configuration 和 mayConfigure
- 新增 agent-runtime library 模块:资源库存放在平台应用数据目录,read 带修订号,save 只在修订号未变时替换,
apply 把用户选中的一项改动写进一个 Agent(指令文件整份重写、技能用符号链接、MCP 与 Hooks 交给插件 edit 改暂存副本,
Core 校验后原子替换,期间文件被改动就拒绝);importSkill、removeSkill 管理技能目录
- 新增宿主命令 agentLibrary.configure/read/save/apply/importSkill/removeSkill,写操作只接受用户发起的请求
- 新增 agentLibrary.* 错误码(一码一义)与日志事件 agent.library.*,日志只带分类码和计数
- 契约 README、schema、fixture(agents 插件补配置声明,invalid-manifests 新增 10 个拒绝用例)、
agents 领域参考、能力版本页、API 总表、四种官方 SDK 说明同步补充
- 协议更新记录:新增本 PR 待合入条目,回填 #220 的合入日期(其余 19 条过期记录见 #222)
…ad 可以读 CLI 自己装的内容
There was a problem hiding this comment.
Devin Review found 4 potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| let bytes = serde_json::to_vec_pretty(&file).map_err(|_| write_failed())?; | ||
| write_replacing(&path, &bytes).map_err(|_| write_failed())?; |
There was a problem hiding this comment.
🔴 Oversized saves lock the library
When an otherwise valid library serializes past 8 MiB, save writes it and returns success. The same size limit then blocks both reopening the library and saving a smaller replacement.
Learn more
LibraryData::check limits individual entries, not the serialized file. Library::load refuses files over 8 MiB. The revision check uses the same limit, so a smaller replacement is refused too. The user must repair the file outside the library to recover.
Example: A library with 33 instruction sets of 256 KiB each passes the field limits. Its successful save leaves a file that neither read nor save accepts.
Recommended fix: Check the serialized byte length against MAX_LIBRARY_FILE_BYTES before replacing the file. Test that a refused save preserves the prior revision and contents.
| let bytes = serde_json::to_vec_pretty(&file).map_err(|_| write_failed())?; | |
| write_replacing(&path, &bytes).map_err(|_| write_failed())?; | |
| let bytes = serde_json::to_vec_pretty(&file).map_err(|_| write_failed())?; | |
| if bytes.len() as u64 > MAX_LIBRARY_FILE_BYTES { | |
| return Err(too_large_file()); | |
| } | |
| write_replacing(&path, &bytes).map_err(|_| write_failed())?; |
Was this helpful? React with 👍 or 👎 to provide feedback.
| let mut copied = Copied::default(); | ||
| let outcome = copy_tree(&source, &partial, 0, &mut copied).and_then(|()| { | ||
| let _writing = self.lock_writing(); | ||
| lithe_platform::entries::rename_no_replace(&partial, &destination).map_err(|error| { |
There was a problem hiding this comment.
🟡 Linked skill manifests vanish on import
When a skill’s SKILL.md is a symlink, import_skill accepts it but copy_tree skips it. The import succeeds, yet the skill stays hidden and blocks another import under the same name.
Learn more
skill_description uses read_bounded, which follows links, so import accepts the source as a skill. copy_tree skips symlinks, including SKILL.md. library_skills then omits the copy because it has no manifest, but the duplicate check still rejects the occupied name.
Example: Import a docs skill whose SKILL.md points to a shared description. The import reports success and one skipped entry, but docs does not appear in the library.
Recommended fix: Preserve the documented no-symlink copy policy. Require a regular SKILL.md in the staged copy before renaming it into the library, and clean up with agentLibrary.notSkill if the manifest is missing.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let value = value.trim(); | ||
| if value.starts_with('|') || value.starts_with('>') { | ||
| block = Some((key, value.starts_with('>'), Vec::new())); | ||
| } else { | ||
| values.insert(key, unquote(value)); |
There was a problem hiding this comment.
🟡 YAML comments block skill imports
When SKILL.md has an inline comment after a plain name, front_matter includes the comment in the name. Directory import then rejects the valid skill as having an invalid name.
Learn more
Library::import_skill uses the YAML name for a directory import and falls back to the directory name only when there is no parsed name. A plain YAML scalar ends before a whitespace-separated # comment. The parser retains that comment, so is_skill_name rejects it.
Example: name: docs # Team documentation names the skill docs in YAML. Directory import instead attempts to use docs # Team documentation and returns agentLibrary.invalidSkillName.
Recommended fix: Parse the bounded front matter with a YAML scalar parser, or handle inline comments for plain scalars without treating literal # in quoted scalars as a comment. Add a directory-import test for a commented name.
Was this helpful? React with 👍 or 👎 to provide feedback.
| view.entry["targets"] = json!({ | ||
| "mcpServers": snapshot.targets.mcp_servers.is_some(), | ||
| "hooks": snapshot.targets.hooks.is_some(), | ||
| }); | ||
| view.snapshot = Some(snapshot); |
There was a problem hiding this comment.
🟡 Unresolved configuration appears editable
When a reported target has no resolved path, view still advertises it for MCP servers or hooks. apply_file then rejects the change because there is no file to edit.
Learn more
agent_paths omits a declared file when none of its path candidates resolves. read_snapshot validates returned target IDs against every declaration, so a backend can still report a valid ID for an omitted file. The view advertises the target, and the state maps mark absent items off rather than unsupported. apply_file checks actual resolved paths and refuses to edit the missing target.
Example: main has only a ${env:AGENT_HOME} candidate, and the variable is unset. The plugin reports main as its MCP target, so a library server appears available to turn on, but turning it on returns agentLibrary.noTarget.
Recommended fix: Filter or mask targets without a resolved path before deriving the response’s targets and item states. Keep existing snapshot data readable for the paths that did resolve.
Was this helpful? React with 👍 or 👎 to provide feedback.
* feat(agents): 提示可以带图片,Agent 在清单里声明接受的图片类型(API-45 0 内补充)
清单 agents[].native 新增可选 imageTypes;agents.prompt 新增可选 images [{path}],
Core 按文件开头字节判断类型并检查数量和总大小,didPrompt 带 images [{mimeType, path}]。
四种官方 SDK 新增图片处理方法,没有实现时这一回合以 failed 结束。
更新记录把已合入的 #223 移到 2026-11-28 时间线。
* feat(agents): 提示附件按 ACP 的方式分成图片和文件链接,不限大小
agents.prompt 的 images 改成 attachments:用户选择、粘贴或拖入的文件、文件夹和图片,
最多 64 个,只传路径、不限大小。Core 按文件开头字节把 Agent 在 native.imageTypes
里声明的类型当作图片,其余(含文件夹、空文件、读不了的文件)当作文件链接;
didPrompt 带 {type, path, name, uri, mimeType?}。错误码改为 agents.invalidAttachment、
agents.tooManyAttachments。四种 SDK 改为 prompt_attachments,没有实现时文件链接以
[@name](uri) 并进正文交给 prompt,带图片的回合失败;fixture 补充 Agent plain。
概述 / Summary
API-45(Agent)的
agents0 内补充,给桌面端 1lck/Lithe-IDEA#2492 的 AI 管理窗口 用。用户要在一个独立窗口里统一管理各个 Agent 最常用的四类配置:MCP 服务器、技能、Hooks、指令。可以按 Agent 逐个开关,Agent 自己装的内容只读显示,也可以导入和删除。Agent 的名称和图标都由插件声明(displayName、icon),Core 和宿主不保存任何 Agent 的名称、图标或配置格式。做法分三层:
agents[]新增可选configuration {instructions?, skills?, files?, read?, edit?},并新增权限agents.configuration。instructions是 CLI 读的用户指令文件,skills是用户技能目录,两者都由 Core 直接读写。files是最多 8 个保存 MCP 服务器和 Hooks 的 CLI 配置文件({id, roots}),文件格式只有插件后端知道。${userHome}或${env:NAME}后至少一段。read、edit是普通插件函数:read回答litheAgentConfiguration快照,环境变量和请求头只给名称;edit只改 Core 给的暂存副本,并保留文件里的其他内容。on/off/conflict/unsupported。edit改暂存副本,Core 校验后原子替换,期间文件被改动就拒绝。agentLibrary.*命令都是平台宿主命令;save、apply、importSkill、removeSkill只接受用户发起的请求,插件不能替用户改资源库或 Agent 配置。同一 PR 还有
agentSessions.calls(提交 2148493),给 AI 管理窗口的“用量 → 请求”页用:按时间倒序分页列出scan报告的每一次调用,带 Core 算出的费用、缓存命中率和速度。没有新增能力版本、协议版本或插件宿主方法。旧 Core 以
plugin.manifest.invalid拒绝声明了configuration或agents.configuration的清单,也不回答agentLibrary.*和agentSessions.calls。方法与命令 / Methods and commands
没有新增插件宿主方法或宿主通知。下面都是平台宿主命令(宿主调用 Core),以及插件后端按清单声明实现的普通函数:
agentLibrary.configure(平台宿主命令)userHome和配置路径用到的环境变量agentLibrary.read(平台宿主命令)agentLibrary.save(平台宿主命令)agentLibrary.apply(平台宿主命令)agentLibrary.importSkill(平台宿主命令)agentLibrary.removeSkill(平台宿主命令)agentSessions.calls(平台宿主命令)configuration.read(插件函数,清单声明 ID)files里的 MCP 服务器、Hooks、Hook 事件和 CLI 自带技能configuration.edit(插件函数,清单声明 ID)主要改动 / Changes
rust/crates/plugin-agents/src/lib.rs:解析并校验configuration。files的id唯一。files就必须有read,没有files时不能有read,edit需要read。read的 Agent 需要后端和onAgent:<id>。configuration {instructions, skills, files, editable}。sessionRootVariables也包括配置路径用到的变量。rust/crates/plugin-manifest/src/permissions.rs:新增agents.configuration。有configuration时必须声明,没有时声明即拒绝。agentConfiguration程序,列出全部路径和是否可编辑。rust/crates/agent-runtime/src/library.rs(新增)library.json(服务器、Hooks、指令集);skills/<name>/;state.json(Core 上次写进各 Agent 指令文件的摘要,用来区分“Lithe 写的”和“用户自己写的”);staging/(插件编辑的暂存副本)。read的修订号是library.json的 SHA-256;save只在修订号未变时替换,从不覆盖读不懂的文件。apply:conflict,不覆盖。importSkill:复制时跳过符号链接并回答跳过了哪些。removeSkill:同时移除各 Agent 里指向它的链接。agents.configuration的插件,其 Agent 仍会列出(mayConfigure: false),但从不读取或修改。agentLibrary.*错误码,一码一义(逐个列在契约 Agent configuration 一节)。agent.library.read_finished、read_failed、updated、change_applied、change_failed、skill_import_finished、skill_removed。只带分类码和计数,不带路径、命令、服务器地址或指令正文。rust/crates/agent-runtime/src/records.rs:agentSessions.calls。超出范围的翻页拒绝为agentSessions.invalidPage。rust/crates/agent-runtime/src/lib.rs、rust/crates/core/src/protocol/command.rs、rust/crates/core/src/runtime/dispatcher/agents.rs、rust/contracts/rust-core-api.md。agent-runtime新增tests/library.rs,共 8 个:library_saves_only_unchanged_revisions_and_only_for_the_userservers_and_hooks_change_only_through_a_checked_staged_copya_linked_configuration_file_is_replaced_where_it_pointsinstructions_follow_the_library_and_keep_text_lithe_did_not_writeskills_are_imported_without_links_and_linked_into_agentsagents_without_the_grant_are_listed_but_never_read_or_changedskill_front_matter_and_instruction_text_are_read_as_writtenmalformed_requests_and_a_damaged_library_file_are_refused_each_with_its_own_coderecords_sync_list_search_read_and_sum_through_the_plugin覆盖agentSessions.calls的筛选、翻页和越界拒绝。plugin-agents补充配置声明的解析与拒绝用例。core的agents_are_reviewed_programs加上agentConfiguration程序。shared/plugins/contract/v1/README.md:新增 Agent configuration 一节(声明、资源库、命令、状态、写回规则、错误码);Backend lifecycle 写明配置文件也由后端服务。plugin-manifest.schema.json:新增agentConfiguration定义和agents.configuration权限。agents/agents.plugin.json补充配置声明;manifest/invalid-manifests.json新增 10 个拒绝用例;reference/domains/agents.md(中英):新增“资源库:指令、技能、MCP 服务器与 Hooks”一节,并更新权限、激活、审查、SDK 各处。reference/capabilities-and-versions.md、reference/api-catalog.md:写明 0 内补充和旧 Core 的行为。API 总表只改 API-45 的说明行,因为没有新增插件宿主方法。read、edit。SDK 代码不变。reference/protocol-changelog.md:验证 / Verification
cargo test --workspace:全部通过(132 组测试结果,没有失败)。cargo clippy -p lithe-agent-runtime -p lithe-plugin-agents -p lithe-plugin-manifest -p lithe-core --all-targets -- -D warnings、cargo fmt --check:通过。node shared/plugins/scripts/verify-docs.mjs:通过。日志事件目录检查:通过。invalid-manifests.json的 10 个新用例由 jsonschema 4.25.1 按 draft 2020-12 校验。schema 拒绝其中能表达的部分;“edit需要read”等跨字段规则和现有做法一致,只由 Rust 检查。跟进 / Follow-up
configuration.read、edit,声明配置路径和品牌图标。Agent Hub 插件退役。PINNED_CORE_REVISION换到 main 上的合入提交。